package com.cyw.consumer.route;

import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @Author: CYW
 * @Date: 2021/1/4 15:56
 * 路由模型
 */
@Component
public class RouteConsumer {

    @RabbitListener(bindings = {
            @QueueBinding(
                    value = @Queue,//创建临时队列
                    exchange = @Exchange(value = "directs",type = "direct"),//自定义交换机名称和类型
                    key = {"info","error","warn"}//代表监听info,error,warn三种
            )
    })
    public void receive1(String message){
        System.out.println("message1"+message);
    }

  @RabbitListener(bindings = {
            @QueueBinding(
                    value = @Queue,//创建临时队列
                    exchange = @Exchange(value = "directs",type = "direct"),//自定义交换机名称和类型
                    key = {"error"}//只监听error
            )
    })
    public void receive2(String message){
        System.out.println("message2"+message);
    }

}
